import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerVO, CustomerForm, CustomerQuery } from '@/api/customer/customer/types';
import {CustomerProviderChannelVO} from "@/api/customer/customerProviderChannel/types";

/**
 * 查询下游客户列表
 * @param query
 * @returns {*}
 */

export const listCustomer = (query?: CustomerQuery): AxiosPromise<CustomerVO[]> => {
  return request({
    url: '/customer/customer/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询下游客户详细
 * @param id
 */
export const getCustomer = (id: string | number): AxiosPromise<CustomerVO> => {
  return request({
    url: '/customer/customer/' + id,
    method: 'get'
  });
};

/**
 * 新增下游客户
 * @param data
 */
export const addCustomer = (data: CustomerForm) => {
  return request({
    url: '/customer/customer',
    method: 'post',
    data: data
  });
};


/**
 * 初始化下游客户公司信息
 * @param data
 */
export const newCustomer = () => {
  return request({
    url: '/customer/customer/new',
    method: 'get'
  });
};

/**
 * 修改下游客户
 * @param data
 */
export const updateCustomer = (data: CustomerForm) => {
  return request({
    url: '/customer/customer',
    method: 'put',
    data: data
  });
};

/**
 * 删除下游客户
 * @param id
 */
export const delCustomer = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/customer/' + id,
    method: 'delete'
  });
};

/**
 *
 * 绑定供应商通道
 * @param customerId
 * @param boList
 */
export const bindProviderChannel = (customerId: string | number ,boList:CustomerProviderChannelVO[]) => {
  return request({
    url: '/customer/customer/bindProviderChannel',
    method: 'post',
    data: {
      customerId ,
      boList
    }
  });
};
/**
 * 获取客户绑定的供应商通道列表
 * @param customerId
 */
export const getCustomerChannels = (customerId: string | number) => {
  return request({
    url: `/customer/customer/getProviderChannel/${customerId}`,
    method: 'get',
  });
};
